import request from "@/utils/request.ts";


/**
 * 添加一片新的文章
 */
export const addArticleUrl = () => {
    return request({
        url: '/blog/articles/add',
        method: 'post',
    })
}

/**
 * 通过文章 id 删除文章信息
 * @param params
 * returns
 */
export const deleteArticleUrl = (params: any) => {
    return request({
        url: '/blog/articles/delete',
        method: 'delete',
        params: params
    })
}


// 保存文章
export const saveArticleUrl = (data: any) => {
    console.log("data", data)
    return request({
        url: '/blog/articles/save',
        method: 'post',
        data: data
    })
}

/**
 * 更新文章信息
 * @param data
 */
export const updateArticleUrl = (data: any) => {
    return request({
        url: '/blog/articles/update',
        method: 'put',
        data: data
    })
}


/*获取自己所有的文章信息*/
export function getArticleUrl(params: any) {
    return request({
        url: '/blog/articles/list',
        method: 'get',
        params: params
    })
}

/*通过文章 id 获取文章信息*/
export function getArticleByIdUrl(params: any) {
    return request({
        url: '/blog/articles/getArticleById',
        method: 'get',
        params: params
    })
}


/**
 * home 页面获取最新文章
 */
export function getRecentlyArticleUrl() {
    return request({
        url: '/blog/articles/recently',
        method: 'get'
    })
}

export function getCateGoryAndTagsUrl() {
    return request({
        url: '/blog/category/cateGoryAndTags',
        method: 'get'
    })
}
